<template>
<div class="ch-swith">
  <div > 你将要修改的用户权限是：{{this.$route.query.userkeymsg.userkey_username}}</div>

   <div class="ch-swith-s"><h5>用户权限：  </h5>
    <el-switch
      style="display: block"
      v-model="uservalue"
      active-color="#13ce66"
      inactive-color="#ff4949"
      active-value="1"
      inactive-value="0"
      active-text="允许"
      inactive-text="不允许">
    </el-switch>
    </div>
    <div class="ch-swith-s">
      <h5>修改新闻权限：  </h5>
    <el-switch
    style="display: block"
      v-model="newvalue"

      active-value="1"
      inactive-value="0"
      active-color="#13ce66"
      inactive-color="#ff4949"
      active-text="允许"
      inactive-text="不允许">
    </el-switch>
     </div>
    <div class="ch-swith-s">
      <h5>修改用户权限：  </h5>
    <el-switch
    style="display: block"
      v-model="userkeyvalue"
      active-color="#13ce66"
      inactive-color="#ff4949"
      active-value="1"
      inactive-value="0"
      active-text="允许"
      inactive-text="不允许">
    </el-switch>

    
<!-- <div>{{userkeyvalue}}</div>
<div>{{uservalue}}</div>
<div>{{newvalue}}</div> -->
     </div>
<el-button type="primary" @click="submitForm()">提交</el-button>
</div>
</template>

<script>
   export default {
      data() {
        return {
          id:'',
          username:'',
          newvalue: '',
          uservalue: '',
          userkeyvalue:''
        }
      },
      created() {
        console.log(this.$route.query.userkeymsg);
        if(this.$route.query.userkeymsg.userkey_id){
          this.id=this.$route.query.userkeymsg.userkey_id;


        this.uservalue = ''+this.$route.query.userkeymsg.userkey_user;
       this.newvalue=''+this.$route.query.userkeymsg.userkey_new;
       this.userkeyvalue=''+this.$route.query.userkeymsg.userkey_key;
       console.log("sda"+this.userkeyvalue);

        }else{
          this.$router.push({path:'/userkey/userkeys'});
        }
      },
      methods:{
        submitForm(){
          this.$axios.post(process.env.API_HOST+"/houtai/index/upuserkey",{ id:this.id, newvalue:this.newvalue,uservalue:this.uservalue,userkeyvalue:this.userkeyvalue}).then(res=>{
                    if(res.status===200){
                       //console.log("ss");
                      console.log(res.data);
                        this.open3(res.data.msg);



                    }




                }), res => {
          // 错误回调
                             console.log(res);



                       }

        },
        open3(msg) {
               this.$message({
                 message: msg,
                 type: 'warning'
               });
             },

      }
    };
</script>

<style space>
/*  .ch-swith{
    display: flex;
  } */
  .el-switch{
    width: 200px;
    margin-top: 20px;
    margin-left: 20px;
    }
    .ch-swith-s{
      display: flex;
    }
</style>
